package com.mingte.manghe.support.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SysGeneratordao {

	/**
	 * 查询所有的表名
	 * @return
	 */
	@Select("show tables;")
	List<String> queryAllTableName();

	/**
	 * 根据表名字查询表信息
	 * */
	@Select("select table_name tableName, engine, table_comment tableComment, create_time createTime " +
			"from information_schema.tables where table_schema = (select database()) and table_name = #{tableName}")
	Map<String,Object> queryTable(String tableName);

	/**
	 * 查询传入信息查询表个数
	 * */
	/*@Select("select count(*) from information_schema.tables where table_schema = (select database()) and table_name = #{tableName}")
	int queryTotal(String tableName);*/

	/**
	 * 模糊查询表信息
	 * */
	@Select("select table_name tableName, engine, table_comment tableComment, create_time createTime " +
			"from information_schema.tables where table_schema = (select database()) ")
	List<Map<String,Object>> queryList();

	/**
	 * 查询列信息
	 * */
	@Select("select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra " +
			"from information_schema.columns where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position")
	List<Map<String, String>> queryColumns(String tableName);
}
